#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2006 loswillios
START=65

WAN=$(nvram get wan_ifname)
LAN=$(nvram get lan_ifname)

start() {
    echo -n "Starting UPnP: "
    route add -net 239.0.0.0 netmask 255.0.0.0 $LAN
    upnpd $WAN $LAN
    echo "OK"
}

stop() {
    echo -n "Stopping UPnP: "
    route del -net 239.0.0.0 netmask 255.0.0.0 $LAN
    killall upnpd
    echo "OK"
}

restart() {
        stop
        sleep 5
        start
}
